//Set up the ZIP function object manually, just in case this test is performed
//in standalone mode

var ZIP = ZIP || ( function(){} );
ZIP.namespace = ZIP.namespace || ( function(space) {
    // for now we'll just deal with setting up one name space at a time.
    // the space path is spec'd in the format: s1.s2.s3.etc
    // the returned object will be <this>.path

    var t = this,  // set the base object
        pSects = [],
        nSect;

    if ( space.indexOf('.') > -1 )
    {
        // composite path
        pSects = space.split('.');  // get the individual components of the path
        nSect = pSects.length;
        j = 0;

        // create the appropriate bits of the path
        for (; j < nSect; j++) {
            t[ pSects[j] ] = t[ pSects[j] ] || {};
            t = t[ pSects[j] ];
        }
    
    } else {
        // simple path
        t[space] = t[space] || {};
        t = t[space];
    }
    return t;
} );

/////////////////////////////////////////////////////////////////////////////
function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}
var i = 0, DOM, xx;
function chkLoaded() {
    if ( !(ZIP && ZIP.Cache && ZIP.Cache.DOM) && i<5) {
        console.log('checking...', i++);
        setTimeout(chkLoaded, 10);
    }
    else {
        DOM = ZIP.Cache.DOM(window);
        xx = DOM.id('#consoleDiv');
        xx.innerHTML = '<p>Test Complete!!</p>'
    }
    return;
};

// note file path begins from current directory where the html statup resides.
loadjscssfile("ZIP-DOM.js", "js");
chkLoaded();